package cn.tedu.user.controller;

import cn.tedu.common.vo.JsonResult;
import cn.tedu.user.domain.dto.ClientLoginParam;
import cn.tedu.user.domain.dto.ClientSaveParam;
import cn.tedu.user.domain.dto.Clientupdateparam;
import cn.tedu.user.domain.vo.ClientVO;
import cn.tedu.user.service.ClientService;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/ry/client")
public class ClientController {
@Autowired
    private ClientService clientService;
@PostMapping("login")
public JsonResult login(@RequestBody ClientLoginParam clientLoginParam){
    log.debug("准备处理用户登录业务:ClientLoginParam={}", clientLoginParam);
    String token = clientService.login(clientLoginParam);
    return JsonResult.ok(token);

}
    @PostMapping("save")
    public JsonResult saveUser(@RequestBody ClientSaveParam clientSaveParam){
       log.debug("准备处理用户注册业务:ClientSaveParam={}", clientSaveParam);
       clientService.saveClient(clientSaveParam);
       return JsonResult.ok("保存成功");
    }
    @PostMapping("update")
    public JsonResult updateClient(@RequestBody Clientupdateparam clientupdateparam){
        log.debug("准备处理修改用户业务:Clientupdateparam={}", clientupdateparam);
        clientService.updateClient(clientupdateparam);
        return JsonResult.ok("修改密码成功");
    }
    @PostMapping("delete/{clientId}")
    public JsonResult deleteClient(@PathVariable Long clientId){
        log.debug("删除用户:clientId={}",clientId);
        clientService.deleteClient(clientId);
        return JsonResult.ok();
    }
    


}
